package com.ald.plane_tool.viewpageradapater;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

public class MyFragmentPagerAdapter extends FragmentPagerAdapter {

    private Fragment[] mfragmentList;

    public MyFragmentPagerAdapter(FragmentManager fm, Fragment[] fragmentList) {
        super(fm);
        this.mfragmentList = fragmentList;
    }

    //获取集合中的某个项
    @Override
    public Fragment getItem(int position) {
        return mfragmentList[position];
    }
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {

    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull View container, int position) {
        return super.instantiateItem(container, position);
    }

    @Override
    public void destroyItem(@NonNull View container, int position, @NonNull Object object) {
        super.destroyItem(container, position, object);
    }

    //返回绘制项的数目
    @Override
    public int getCount() {
        return mfragmentList.length;
    }
}